var login_password = "implicit";
var login_input;
var login_lock;
var login_warning;
var login_animationInterval;
var login_popupId="";

function login_show() {
	if (login_warning) {
		main_statusLine.removeChild(login_warning);
		clearInterval(login_animationInterval);
		login_warning=null;
	}
	if (login_password == "implicit") {
		login_warning = document.createElement("span");
		login_warning.className = "loginWarning";
		login_warning.title = _T("ImplicitPasswordWarning");
		login_warning.textContent = "!!!!*";
		login_warning.setAttribute("onClick","login_popup();");
		login_warning.setAttribute("onMouseDown","return false;");
		main_statusLine.appendChild(login_warning);
		login_animationInterval = setInterval(login_animation, 1000);
	}
}

function login_popup(){
	var content=document.createElement("div");
	var text=document.createElement("div");
	text.textContent=_T("ImplicitPasswordExplaination");
	content.appendChild(text);
	popup_showMessage(_T("ImplicitPassword"),content, "" ,"20em") 
}

function login_animation(){
	var oldText=login_warning.textContent;
	var first=oldText.substring(0,1);
	var newText=oldText.substring(1);
	login_warning.textContent=newText+first;
}

function login_login() {
	if (!login_lock) {
		login_lock = true;
		login_input = document.createElement("input");
		login_input.type = "password";
		login_input.onkeypress=login_onKeyPress;
		var content = document.createElement("div");
		content.appendChild(login_input);
		login_popupId=popup_showMessage(_T("PasswordRequested"), content,"login_savePassword();").id;
	}
}

function login_onKeyPress(_event) {
	var code = _event.keyCode;
	switch (code) {
	case 13:
		login_savePassword();
		break;
	default:
		return true;
	}
	return false;
}

function login_savePassword() {
	login_password = login_input.value;
	popup_hide(login_popupId);
	login_lock = false;
	main_anime();
}